<?php
	require_once( "includes/login_throw.inc.php" );
	require_once( "includes/common.inc.php" );
		
	if ( !isset( $_GET['id'] ) && !isset( $_POST['email_find'] ) )
	{
		printFormFind();
		return;
	}
	
	$engine = new UserInfoEngine();
	
	$email = "";
	$result = "";
	$isErr = false;
	
	if ( $engine->checkSetId() )
	{
		$getEmail = NULL;
		try 
		{
			$getEmail = $engine->getEmailFromId( $_GET['id'] );
		}
		catch ( Exception $e )
		{
			$result .= $e->getMessage();
			$isErr = true;
		}
		if ( $getEmail != NULL )
		{
			$email = $getEmail;
		}
	}
	else if ( $engine->checkSetEmail() )
	{
		$email = $_POST['email_find'];
	}
	
	try 
	{
		$isValid = $engine->isDataTaken( $email, &$result );
	}
	catch ( Exception $e )
	{
		$result .= $e->getMessage();
		$isErr = true;
	}
	
	$vars = array( 
					'Title' => 'User Info',
					'mode' => ( $isErr ) ? ( "Error" ) : ( "Succes" ),
					'message' => $result,
					'logScript' => checkLog().".php",
					'logMode' => checkLog(),
				 );
				 
	$vars['menu'] = printMenu();
	$vars['content'] = getView('templates/get_user_info.tpl', $vars);
	
	buildLayout('templates/head.tpl', $vars);
?>